Command Service
Command Service is a combination of 3 services:
Customer Service is a service that manipulate database and can be accessed by Gateway via REST API. This service stores customer information such as phone number, customer information, activities on the system.
User Service is one of a service that manipulate database and can be accessed by Gateway via REST API. This service stores user data, role data, sip account
Third party service is a service that manages the integration information of external systems and provides these integration information for the integration service to execute
It only communicates with the access-service. A username and a password, exemplifying Basic Access Authentication, must be validated.
I. Functionality
- Create, store, and manipulate
customer-servicedatabase- Create, store, and manipulate
Activity: calllog, send sms,... - Create, store, and manipulate
ContactGroup: Contact information in a group - Create, store, and manipulate
Contact: Information of contact
- Create, store, and manipulate
- Create, store, and manipulate
user-servicedatabaseAgent: this is where the user's information is stored in a callcenterRole: By default, there are two roles: admin and agent. In addition, you can customize the role yourselfSipAccount: Save information about sip account from provider
- Create, store, and manipulate
third-party-servicedatabase- Create, store, and manipulate
Integration Template - Create, store, and manipulate
Integration Endpoint - Create, store, and manipulate
Integrator
- Create, store, and manipulate
- Authorize via a username and a password, exemplifying Basic Access Authentication
II. Packages
1. Dependencies
- Express - Node.js web application framework: Express
- MongoDB - Node.js Driver: MongoDB
- Dotenv - Storing configuration: Dotenv
- Body-parser - Node.js body parsing middleware: Body-parser
- Winston - A multi-transport async logging library for node.js: Winston
- Winston-daily-rotate-file - A transport for winston which logs to a rotating file each day: Winston-daily-rotate-file
- Morgan - HTTP request logger middleware for node.js: Morgan
- Bluebird - A full featured promise library with unmatched performance: Bluebird
2. Dev Dependencies
- Mocha - The fun, simple, flexible JavaScript test framework: Mocha
- Chai - Assertion library for node: Chai
- Chai as Promised - Chai assertions for promises: Chai Promised
- Chai HTTP - HTTP Response assertions for the Chai Assertion Library: Chai HTTP
- Istanbul - A JavaScript test coverage tool: Istanbul
- Nyc - Istanbul's state of the art command line interface: Nyc
- ESLint - The pluggable linting utility for JavaScript and JSX: EsLint
III. Database
1. ERD
- ERD customer-service

- ERD user-service

- ERD third-party-service

2. Database schema
Activity
Activity of an agent goes along with a contact. Indeed, every call center has a distinct collection to store their call logs. The collection names follow the format activity_idCallcenter
| Field | Type | Description |
|---|---|---|
| _id | string | Unique identity string |
| creator | string | _id of the agent creating the activity |
| idContact | string | _id of the contact involved |
| text | string | Description of the activity |
| type | string | Three accepted values of activity category are note, calllog, and reminder |
| body | object | If type is calllog, body includes idCalllog, status, duration, direction, source, destination, start, and end. If type is reminder, body includes remindedAgent, duedate, and status |
| body.status | string | If type is calllog, five accepted values are success, missed, rejected, busy, and connected. If type is reminder, two accepted values are checked and unchecked |
| body.idCalllog | string | _id of the call |
| body.duration | number | Length of call, measured in seconds |
| body.direction | string | Direction of the call, two accepted values are incoming and outgoing |
| body.source | string | Caller of the call |
| body.destination | string | Recipient of the call |
| body.start | number | Timestamp of the call initiation, in number of milliseconds since Unix epoch |
| body.end | number | Timestamp of the call end, in number of milliseconds since Unix epoch |
| body.remindedAgent | string | _id of agent reminded |
| body.duedate | number | Timestamp of the deadline on schedule, in number of milliseconds since Unix epoch |
| createdAt | int64 | Timestamp of the document creation, in number of milliseconds since Unix epoch |
| updatedAt | int64 | Timestamp of the last update, in number of milliseconds since Unix epoch |
| deleted | boolean | Status of visibility |
ContactGroup
ContactGroup provides information about a group of contacts chosen by an agent individually in their view. Indeed, every call center has a distinct collection to store their groups. The collection names follow the format contactGroup_idCallcenter
| Field | Type | Description |
|---|---|---|
| _id | string | Unique identity string |
| name | string | Name of the group |
| description | string | Description of the group |
| creator | string | _id of the agent creating the group |
| contactList | array | Each item is the _id of agent in the group |
| createdAt | int64 | Timestamp of the document creation, in number of milliseconds since Unix epoch |
| updatedAt | int64 | Timestamp of the last update, in number of milliseconds since Unix epoch |
| deleted | boolean | Status of visibility |
Contact
Contact provides information of a contact. Indeed, every call center has a distinct collection to store their contacts. The collection names follow the format contact_idCallcenter
| Field | Type | Description |
|---|---|---|
| _id | string | Unique identity string |
| firstName | string | First name of the contact |
| lastName | string | Last name of the contact |
| gender | string | Gender of the contact |
| string | Email of the contact | |
| phone | string | Phone number of the contact |
| avatar | string | Avatar of the contact |
| createdAt | int64 | Timestamp of the document creation, in number of milliseconds since Unix epoch |
| updatedAt | int64 | Timestamp of the last update, in number of milliseconds since Unix epoch |
| deleted | boolean | Status of visibility |
Agent
Agent is a person who works for a call center. Indeed, every call center has a distinct collection to store their agents. The table name follows the format agent_idCallcenter
| Field | Type | Description |
|---|---|---|
| _id | string | Unique identity string |
| role | string | Role assigned to the agent, two accepted values are admin and agent |
| idSip | string | _id of SIP account assigned to the agent |
| createdAt | int64 | Timestamp of the document creation, in number of milliseconds since Unix epoch |
| updatedAt | int64 | Timestamp of the last update, in number of milliseconds since Unix epoch |
| deleted | boolean | Status of visibility |
Role
Role is assigned to each agent to determine their authorization. Indeed, every call center has a distinct table to store their roles. The table name follows the format role_idCallcenter
| Field | Type | Description |
|---|---|---|
| _id | string | Unique identity string |
| name | string | Name of the role, two accepted values are admin and agent |
| createdAt | int64 | Timestamp of the document creation, in number of milliseconds since Unix epoch |
| updatedAt | int64 | Timestamp of the last update, in number of milliseconds since Unix epoch |
| deleted | boolean | Status of visibility |
SipAccount
A SipAccount provides authentication credentials to log in a SIP account. Indeed, every call center has a distinct table to store their SIP accounts. The table name follows the format sipAccount_idCallcenter
| Field | Type | Description |
|---|---|---|
| _id | string | Unique identity string, in this case, the hotline number |
| domain | string | Domain of the SIP account |
| extension | string | Number of extension in SIP URI |
| password | string | Password to get access to call connection |
| proxy | string | Proxy the of SIP account |
| createdAt | int64 | Timestamp of the document creation, in number of milliseconds since Unix epoch |
| updatedAt | int64 | Timestamp of the last update, in number of milliseconds since Unix epoch |
| deleted | boolean | Status of visibility |
ClickToCall
ClickToCall includes information about customized Gcall button of call centers. Each call center only has one click-to-call button
| Field | Type | Description |
|---|---|---|
| _id | string | Unique identity string |
| idCallcenter | string | _id of the call center |
| header | string | Header of the button |
| content | string | Body description of the button |
| color | string | Color of the button |
| position | string | Position of the button, five accepted values are bottom-left, bottom-right, bottom-center, left-center, and right-center |
| delay | number | Number of seconds between loading the button and releasing it |
| activated | boolean | Status of the button |
| deleted | boolean | Removal status of the record |
| createdAt | int64 | Timestamp of the document creation, in number of milliseconds since Unix epoch |
| updatedAt | int64 | Timestamp of the last update, in number of milliseconds since Unix epoch |
| deleted | boolean | Status of visibility |
SipProvider
SipProvider provides information about providers that supply SIP accounts
| Field | Type | Description |
|---|---|---|
| _id | string | Unique identity string |
| name | string | Name of the provider |
| phone | string | Phone number of the provider |
| phoneList | array | List of phone numbers provided, each is a string |
| tollCost | string | Toll cost of using the provider's service |
| firm | string | Firm name of the provider |
| innerCost | string | Inner cost of using the provider's service |
| outerCost | string | Outer cost of using the provider's service |
| serviceCost | string | Installmen cost of using the provider's service |
| deleted | boolean | Removal status of the record |
| createdAt | int64 | Timestamp of the document creation, in number of milliseconds since Unix epoch |
| updatedAt | int64 | Timestamp of the last update, in number of milliseconds since Unix epoch |
| deleted | boolean | Status of visibility |
III. Source tree
https://gitlab.com/gcalls/publics/gcallsback/-/tree/Test/commandService
IV. Installation
- Clone project:
git clone https://gitlab.com/gcalls/publics/gcallsback
- Change dir into commandService folder
cd commandService
- Install packages:
npm install
Start service:
run in development
npm run devrun in production
npm install -g pm2
npm start
Test:
npm run test
V. Endpoint
Please visit API documentation for more details